package com.example.myapplication.Fragment;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.myapplication.activity.LoadingActivity;
import com.example.myapplication.R;
import com.example.myapplication.adapter.recyclerViewAdapter.RecyclerRecommendSongAdapter;
import com.example.myapplication.entity.RecommendSongs;

import java.util.List;

public class RecommentSongFragment  extends Fragment {
    private View view;
    private RecyclerView recycler_recomment_song;
    private Context context;
    private List<RecommendSongs.DataBean.DailySongsBean> recommendSongsList;
    private RecyclerRecommendSongAdapter adapter;


    public static Fragment newInstance(){
        RecommentSongFragment f =  new RecommentSongFragment();
        return f;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_recomment_song, container, false);
        init();
        return view;
    }

    private void init() {
        recycler_recomment_song = view.findViewById(R.id.recycler_recomment_song);
        RecyclerView.LayoutManager manager_ver = new LinearLayoutManager(getContext());
        recycler_recomment_song.setLayoutManager(manager_ver);
        adapter = new RecyclerRecommendSongAdapter(getContext());
        loadData();

    }


    private void loadData(){
                adapter = new RecyclerRecommendSongAdapter(getContext());
                adapter.setData(LoadingActivity.recommendSongsList);
                recycler_recomment_song.setAdapter(adapter);

    }

}
